`<`h1`>`Development Documentation`<`/h1`>`

`<`h2`>`dom structure`<`/h2`>`

= fixedboard =

div class='cs__fixedboard_container'

 * div: class='cs__fixedboard_title
 * div: class='cs__fixedboard_info' style='display:none;'
 * div: class='cs__board_container'
 * div: class='cs__fixedboard_loadpgn'
 * div: class='cs__fixedboard_control'
 * div: class='cs__fixedboard_gamelist'

= board =

div class='cs__board_container'

 * idv class='cs__promotion_notify'
 * table class='cs__board'
 * div class='cs__promotion_notify'
 * table class='cs__panel'
  * pre_comment: tr class='cs__comment' td input
  * panel: tr panel
   * td board open/close
   * td's directions
   * td class='cs__board_last_move'
  * nar: tr class='cs_comment' td radio
  * finish: tr class='cs_comment' td radio
  * comment: tr class='cs__comment' td textarea


= movelist =

div class='cs__movelist_container'
 * div class='cs__movelist_head'
 * div class='cs__l`[`0-9`]`'
  * pre_comment: span class='cs__comment'
   * upre_comment: span class='cs__ucomment
  * `<`whitespace`>`
  * move_no: span class='cs__move_no'
  * `<`whitespace`>`
  * href: a onclick='`<`move`>`.jump()'
  * `<`whitespace`>`
  * comment: span class='cs__comment'
   * ucomment: span class='cs__ucomment
   * board: div class='cs__board_container
  
 


`<`h2`>`classes`<`/h2`>`

= chess_spider class =

 * configuration attributes
  * interactive - whether user is allowed to create own moves, default true
  * fixedboards
   * fixedboard_id
   * object
    * title - if text, board title; if false, no title; if null, from game headers
    * info - whether able to show pgn headers from title
    * params - whether to attach control params, eg, font to use
    * loadpgn - whether to attach ability to load new pgn
    * gamelist - whether to show list of games from pgn (do not confuse with movelist)
  * fixedboard_dflt - id of the default fixed board that will be used when a game is displayed
  * movelists
   * movelist_id
   * object
    * head - whether (or what) head (title) for movelist
    * reposition - whether to reposition movelist after loading or resize window
  * movelist_dflt - id of the default fixed board that will be used when a game is displayed
  * control
   * disp_font - symbol, english
   * disp_piece - img, div (this will use font)
 * dynamic attributes
  * game_arr - may be initialized manually or dynamically via parsePgn
  * moves - all moves indexed by Move.id
 * methods
  * lastMsg - helper function, returns session.message_arr`[`last`]`
 * chess_spider.com
  * Message - messaging methods to server
   * attributes
    * idx - index into message_arr
    * uri - complete uri
    * tx_ts - when sent
    * rx_ts - when received
    * status - message status
    * result - result from server
   * methods (all static helper methods)
    * Message( action, args, successFunc, failureFunc ) - called by helpers
     * adds self to session.message_arr
     * makes asynchronous uri call
     * on result, calls successFunc or failureFunc
    * init() - initialize: set connect_ts, hash, and user if logged in
    * login( login, pwd ) - login this user
    * logout() - logout this user
  * session
   * state: normal, login, sending
   * xmlHttp - xml http socket for chess spider - set at init
   * connect_ts - when initial sync with server took place
   * login_ts - when logged in
   * message_arr`[``]`
   * hash - last hash rxd from server
   * rand - random number set when init'd
  * user
   * login - login as sent to server
   * name - name as returned by server
 


= Move =

 * base attributes
  * game
  * move_no - move number
  * move - algebaric notation of move
 * topological attributes
  * prv - previous move as displayed
  * pnt - logical previous move
  * nxt - next move in same level
  * level - level, main level being 1
  * branch - branch no, main branch being 0
  * id - G`<`i`>`game_idx`<`/i`>`L`<`i`>`level`<`/i`>`B`<`i`>`branch`<`/i`>`M`<`i`>`move_no`<`/i`>`C`<`i`>`color`<`/i`>` - referenced in game.moves`[`id`]`
 * calculation attributes
  * piece - piece being moved (if castling, king)
  * color - w/b
  * src_sq - from square
  * tgt_sq - to square
  * capture - whether capturing
  * castle - 0-0, 0-0-0, or null
  * pstn - postition after move
 * comment attributes
  * mode - pgn, user
  * pre_comment
  * upre_comment
  * comment
  * ucomment
  * nar - index into nar_arr
  * finish - finish off notation, eg, 0-1
 * dom attributes created when inserting into dom (in physical order)
  * dom_pre - pre_comment span (optional)
  * dom_pre_ws - whitespace following pre_comment span (will always follow pre_comment)
  * dom_move_no - move_no span (optional)
  * dom_move_no_ws - whitespace following move_no span (will always follow move_no)
  * dom_href - move itself, including nar and finish
  * dom_href_ws - whitespace following move (will always follow href)
  * dom_post - comment span (optional)
  * board - board associated with # in comment or ucomment
  * dom_post_ws - whitespace following comment (will always follow comment)
 * methods
  * attach( board ) - attach this user created move to a board as last move
  * delete() - delete move from all its contexts
  * domAdd() - add this move to same movelist as used by prv
  * get(square) - return piece on square
  * getColor(square) - return color of piece on square - ' ' if no piece
  * getEnPassant() - returns tgt_sq from previous move if pawn forward two rows
  * getLastDomNode() - get last dom node for this move
  * genMove(board,src_sq,tgt_sq) - create new user move - false if invalid
  * getMove() - return correctly formatted move
  * href() - return href for this move
  * isLowerMove(lwr) - whether lwr move precedes this move
  * isNextMove(nxt) - whether nxt is a possible next move for this
  * jump() - jump to this move on current board
  * listCaptures( sq, piece, color ) - return array of possible captures by piece of this color on this square
  * listCastles() - returns array of possible castling moves at current position
  * listMoves( sq, piece, color ) - return array of possible moves of piece of this color on this square
  * listPieceSquares( piece, color ) - return array of squares having piece of this color on them
  * oppColor() - opposite color of current move
  * pstnPop() - pop previous pstn from stack
  * pstnPush(s1,p1,s2,p2) - push current pstn onto stack, setting current square1 to piece1 and square2 to piece2
  * reApply() - apply last part of move (first part may have been verification)
  * set(square,piece) - put piece on square
  * showComments(tp) - show move's comments in movelist and boards where cur_mv
  * showMoveNo(tp) - show move's move_no in movelist
  * userDelete(all) - delete this user move and it's children
  * inCheck() - return whether opposing king is in check
  * inMate() - return whether opposing king is mated
 


= Game =

 * init attributes
  * fixedboard_id - id of fixed board associated with game
  * movelist_id - document id of movelist block
  * pgn - either uploaded or static
  * init_pstn - if null then orig_pstn
  * active - whether displayed on page
 * runtime attributes
  * idx - index of this game in game_arr
  * upgn - user's pgn (as would be appended to pgn)
  * headers - from pgn parse
  * cur_bd - current board
 * non-instance methods
  * display( game_idx, movelist_id, fixedboard_id ) - helper for game.display
 * methods
  * Game( pgn ) - creates new game
  * display( movelist_id, fixedboard_id ) - displays game on page
  * parsePgnMeta() - pulls out meta from pgn
  * parsePgnMoves( rootMove ) - pulls out moves from pgn - todo: is rootMove necessary?
  * fullTitle() - get full title from meta
  * (deprecated?)  reDispMoves() - redisplay moves in game - used when changing move font, for example
  * writeTitle() - get title from meta
  * setCur( board ) - set current board to board


= MoveList =

 * config attributes
  * head - false = none, text = constant title, null = pull from game
  * reposition - whether to reposition in parentNode - default true
 * runtime attributes
  * movelist_id - id of movelist, where it will be attached
  * game - game movelist is showing
  * dom_div - div containing movelist
 * non-instance methods
  * initAll() - initializes all gamelists in chess_spider.gamelists
  * display( gamelist_id, game ) - helper for fixedboard.display()
 * methods
  * MoveList( movelist_id, head, reposition ) - will add to chess_spider.movelists`[`movelist_id`]`
  * reposition( how ) - reposition movelist within its parent


= FixedBoard =

 * config attributes
  * title - false = none, text = constant title, null = pull from move.game
  * info - whether allow pgn header info in fixedboard
  * loadpgn - whether allow pgn upload in fixedboard
  * control - whether allow control panel in fixedboard
  * gamelist - whether allow gamelist in fixedboard
 * runtime attributes
  * fixedboard_id - id of fixedboard, where it will be attached
  * dom_div - div containing fixedboard - may or may not be attached to dom_id
  * board - the board for this fixedboard
 * non-instance methods
  * initAll() - initializes all boards in chess_spider.fixedboards
  * fixedboards() - get all fixedboards instantiated in document
  * display( fixedboard_id, `[`game`]`, `[`action=show`]` ) - helper for fixedboard.display()
 * methods
  * FixedBoard( dom_id, title, info, params, loadpgn, gamelist  ) - create FixedBoard and attach to cs.fixedboards`[`dom_id`]`
  * display( `[`game`]`, `[`action=show`]` ) - `[`sets game in board`]`, show or hide fixedboard in dom
  * reposition( how ) - reposition fixedboard within its parent
  * writeTitle( title ) - write title and info to dom_div
 * dom methods
  * title() - fixedboard title
  * info() - fixedboard info
 


= Board =

 * attributes
  * dom_id - document id where to put board - this also serves as board id in cs.fixedboards
  * root_mv - root move for board
  * cur_mv - current move for board
 * methods
  * Board( move ) - root move for board (move may be null and set later)
  * display() - displays cur_mv in board
  * promotion_notify( color ) - pointer to promotion notify for white or black
  * attach( dom_id ) - attach board to document replacing dom_id
  * setMove( move ) - sets move on board as root_mv, positions board to move
  * userJump( idx ) - sets cur_mv to board to idx, which can be string, id, or move
  * set( file_row, piece, color ) - sets board's square file_row to piece/color
  * setCur() - set this board as current board for game
 * dom methods
  * pre_comment() - pre_comment input
  * table() - board table
  * promotion(color) - promotion at top or bottom of board
  * comment() - comment textarea
  * panel() - panel
  * last_move() - last_move td in panel
  * loadpgn() - loadpgn tr
  * control() - control tr
  * gamelist() - gamelist tr
 * helper methods
  * dom_comment_tr() - in panel, comment tr
  * dom_comment_input() - in panel, comment textarea
  * dom_finish_tr() - finish row in panel
  * dom_last_move() - last_move td in panel
  * dom_nar_tr() - nar row in panel
  * dom_panel() - dom panel table
  * dom_pre_comment_tr() - in panel, pre_comment tr
  * dom_pre_comment_input() - in panel, pre_comment input
  * dom_promotion( color ) - in panel, promotion notify area top and bottom of board
  * dom_table() - table associated with this board
  * fixedboard() - fixedboard parent of this board (if exists)
  * setCur() - sets this as current board (if it has move attached)
 



`<`h2`>`initialization`<`/h2`>`

= pre-onload =


* chess_spider.initFixedBoards()
 * internally initializes fixed boards as found in chess_spider.fixedboards
* chess_spider.parsePgn()
 * parses pgn as found in chess_spider.pgn
 * if pgn is url, then loads it from url first
 * inserts (or updates) chess_spider.game_arr`[``]` element for each game in pgn
  * if new: movelist = chess_spider.movelist_dflt; fixedboard = chess_spider.fixedboard_dflt
 



= onload =


* chess_spider.Game.display( game_idx, movelist_id, fixedboard_id )
 * if movelist_id or fixedboard_id is undefined, taken from chess_spider.game_arr
 * if game_idx is undefined, then each game in chess_spider.game_arr is displayed, starting with 0



